package com.evil.enterprise.controller;

import com.evil.application.api.RemoteApplicationStatisticsService;
import com.evil.application.pojo.dto.statistics.*;
import com.evil.common.application.dto.order.OrderPageDataRespDTO;
import com.evil.common.core.entity.QueryModel;
import com.evil.common.core.entity.R;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 应用统计接口
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/application/statistics")
public class ApplicationStatisticsController {

    private final RemoteApplicationStatisticsService applicationStatisticsService;

    /**
     * 统计
     *
     * @return R
     */
    @PostMapping("/query-type")
    public R<List<StatisticsRespDTO>> statistics(@Validated @RequestBody StatisticsAppDataReqDTO statisticsAppDataReqDTO) {
        return R.success(applicationStatisticsService.statistics(statisticsAppDataReqDTO));
    }

    /**
     * 统计登录人待办
     *
     * @return R
     */
    @PostMapping("/pending")
    public R<List<StatisticsPendingRespDTO>> statisticsPending() {
        return R.success(applicationStatisticsService.statisticsPending());
    }

    /**
     * 登录人待办page
     *
     * @return R
     */
    @PostMapping("/pending/page")
    public R<PageInfo<OrderPageDataRespDTO>> statisticsPendingPage(@Validated @RequestBody QueryModel<StatisticsPendingPageReqDTO> queryModel) {
        return R.success(applicationStatisticsService.statisticsPendingPage(queryModel));
    }

    /**
     * 统计登录人订单
     *
     * @return R
     */
    @PostMapping("/order")
    public R<List<StatisticsOrderRespDTO>> statisticsOrder() {
        return R.success(applicationStatisticsService.statisticsOrder());
    }

    /**
     * 登录人订单page
     *
     * @return R
     */
    @PostMapping("/order/page")
    public R<PageInfo<OrderPageDataRespDTO>> statisticsOrderPage(@Validated @RequestBody QueryModel<StatisticsOrderPageReqDTO> queryModel) {
        return R.success(applicationStatisticsService.statisticsOrderPage(queryModel));
    }
}
